import javax.swing.JOptionPane;
import javax.swing.Timer;

import java.awt.Toolkit;
import java.awt.event.*;
import java.time.Instant;

class Timerpointer implements ActionListener{

    @Override
    public void actionPerformed(ActionEvent e) {
       System.out.println(" at the tong , the time is "
                +Instant.ofEpochMilli(e.getWhen()));
        Toolkit.getDefaultToolkit().beep();

    }

}
public class Timerdemo{
    public static void main(String[] args){
        var listener = new Timerpointer();
        var timer = new Timer(1000, listener);
        timer.start();
        JOptionPane.showMessageDialog(null, "quit program?", null, 0);
        System.exit(0);
    }
}